local tairan = fk.CreateSkill{
    name = "jinhs__tairan",
}

Fk:loadTranslationTable{
    ["jinhs__tairan"] = "泰然",
    [":jinhs__tairan"] = "结束阶段，若你的体力值于此回合内发生过变化，你可以摸X张牌并展示之，若其中包含应变牌，你回复1点体力（X为你已损失的体力值）。",

    ["$jinhs__tairan1"] = "撼山易，撼我司马氏难。",
    ["$jinhs__tairan2"] = "云卷云舒，处之泰然。",
}

tairan:addEffect(fk.EventPhaseEnd,{
    anim_type = "support",
    can_trigger = function (self, event, target, player, data)
      return target == player and player:hasSkill(tairan.name) and player:isWounded() and player.phase == Player.Finish
      and #player.room.logic:getEventsOfScope(GameEvent.ChangeHp, 1, function (e)
        return e.data.who == player
      end, Player.HistoryTurn) > 0
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local x = player:getLostHp()
        local cards = player:drawCards(x, tairan.name)
        room:showCards(cards, player)
        room:delay(300)
        local num = 0
        for _, c in ipairs(cards) do
          local card = Fk:getCardById(c)
          if table.find({"@fujia-public", "@kongchao-public", "@canqu-public", "@zhuzhan-public", "@heg_yibing-public"}, function(mark)
          return card.extra_data and card.extra_data.heg_variation and card.extra_data.heg_variation[1] == mark end) then
          num = num + 1
          end
        end
        if num > 0 and player:isWounded() then
        room:recover{
            who = player,
            num = 1,
            skillName = tairan.name,
        }
      end
    end,
})

return tairan